﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;

using EHTWebsite.Code;
using EHTWebsiteProject.Code.BLL;
using System.Resources;
using System.Threading;
using System.Globalization;
using System.Text;
using Telerik.Web.UI;
using System.Collections.Generic;
using EHTWebsiteProject.Code.Entity;

namespace EHTWebsiteProject.Administrator
{
    public partial class EHTContactUsDetails : System.Web.UI.Page
    {
        public Boolean IsVN = true;
        private String languageCode = "vi-VN";
        private ResourceManager rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));
        private Int32 LienHeID= HangSo.DEFAULT_ID;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AjaxPro.Utility.RegisterTypeForAjax(typeof(EHTWebsiteProject.Administrator.EHTContactUsDetails));
                try
                {
                    languageCode = Session[HangSo.LANGUAGE_CODE].ToString();
                    if (languageCode == "en-us")
                    {
                        IsVN = false;
                    }

                }
                catch (Exception ex)
                {
                }

                try
                {
                    LienHeID = Int32.Parse(Request.QueryString["LienHeID"].ToString());
                    Session["LienHeID"] = LienHeID.ToString();
                }
                catch
                {

                }


                Thread.CurrentThread.CurrentCulture = new CultureInfo(languageCode);
                LoadLanguage(Thread.CurrentThread.CurrentCulture);
                LoadContactUS(LienHeID);                
            }
        }
        /// <summary>
        /// Ham load ngon ngu
        /// </summary>
        /// <param name="ci"></param>
        public void LoadLanguage(CultureInfo ci)
        {
            lbContactUS.Text = rm.GetString("lbContactUS", ci);            
            lbHelp.Text = rm.GetString("lbHelp", ci);
            lbBack.Text = rm.GetString("lbBack", ci);
            lbDel.Text = rm.GetString("lbDel", ci);
           
            this.ltrDiaChi.Text = rm.GetString("ltrDiaChi", ci);
            this.ltrDienthoai.Text = rm.GetString("ltrDienthoai", ci);
            this.ltrHoTen.Text = rm.GetString("ltrHoTen", ci);
            this.ltrNgayLienHe.Text = rm.GetString("ltrNgayLienHe", ci);            
            this.ltrNoiDung.Text = rm.GetString("ltrNoiDung", ci);
            this.lbEmail.Text = rm.GetString("lbEmail", ci);
            this.ltrStatus.Text = rm.GetString("ltrStatus", ci);
        }


        [AjaxPro.AjaxMethod]
        public void LoadContactUS(Int32 LienHeID)
        {
            LienHe theLienHe = LienHeProvider.GetLienHeByLienHeID(LienHeID);
            lbDiaChi.Text = theLienHe.DiaChi;
            lbDienThoai.Text = theLienHe.DienThoai;
            ltrEmail.Text = theLienHe.Email;
            lbHoTen.Text = theLienHe.HoTen;
            lbNgayLienHe.Text = theLienHe.NgayLienHe.ToShortDateString();
            lbNoiDung.Text = theLienHe.NoiDung;
            if (theLienHe.TrangThaiDoc == true)
            {
                if (IsVN == true)
                    lbTrangThaiDoc.Text = HangSo.View_VN;
                else
                    lbTrangThaiDoc.Text = HangSo.View_Other;
            }
            else
            {
                if (IsVN == true)
                    lbTrangThaiDoc.Text = HangSo.NoView_VN;
                else
                    lbTrangThaiDoc.Text = HangSo.NoView_Other;
            }

        }

        protected void ImgDel_Click(object sender, ImageClickEventArgs e)
        {
            LienHeProvider.DeleteLienHeByLienHeID(Int32.Parse( Session["LienHeID"].ToString()));
            Response.Redirect("EHTContactUs.aspx");
        }
       
    }
}